/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.cemaden.smp.controler;

import br.gov.cemaden.library.model.smp.CPUAplic;
import com.sun.management.OperatingSystemMXBean;
import java.io.Serializable;

/**
 *
 * @author Simone Santos
 */
public class CPUAplicBean implements Serializable {

    CPUAplic cpu = new CPUAplic();

    public CPUAplicBean() {
    }

    public CPUAplic get(OperatingSystemMXBean remoteOperating) {

        double percent = Math.round((remoteOperating.getProcessCpuLoad() * 100) * 100.0) / 100.0;

        cpu.setCpuUsage(percent);
        return cpu;
    }

    public void show(CPUAplic t) {

        String separator = "--------------------------------";

        System.out.printf("CPU Usage%nCPUUsage: %f%n%s%n", t.getCpuUsage(), separator);
    }
}
